package com.vipheyue.bigcompany.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;

import com.vipheyue.bigcompany.R;
import com.vipheyue.bigcompany.utils.DataUtil;

/**
 * 浸入式状态栏 values-v19 设置  <item name="android:windowTranslucentStatus">true</item> 即可
 * 在布局中使用    android:fitsSystemWindows="true" 防止状态栏被占据
 *     StatusBarCompat.compat(this, 0xFFFF0000);
 *     可以设置状态栏颜色tatusBarCompat.compat(this, getResources().getColor(R.color.status_bar_color));
 //         StatusBarCompat.compat(this);
 主题 Theme.AppCompat.Light.NoActionBar
 */
public class SplashActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_splash);
        startActivity();
    }

    private void startActivity() {

            new Handler().postDelayed(new Runnable() {//延迟进入主界面
                @Override
                public void run() {
                    SharedPreferences  sp= DataUtil.getSP(SplashActivity.this);
                    boolean isFirstUse = sp.getBoolean("isFirstUse", true);
                    if (isFirstUse) {
                        Intent intent = new Intent(SplashActivity.this, BootStrapperActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        Intent intent = new Intent(SplashActivity.this, loginActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }
            }, 2000);//启动时间
        }
}